﻿using System;
using System.Collections.Generic;
using MyMovieCollection.com.amazon.webservices;
using MyMovieCollection.DATA.Models;

namespace MyMovieCollection.Util
{
    public class AmazonSearcher
    {
        public static  List<Movie> SearchByTitle(string title)
        {
            AWSECommerceService  service=new AWSECommerceService();
            ItemSearchRequest request = new ItemSearchRequest();
            request.SearchIndex = "DVD";
            request.Title= title;
            request.ResponseGroup = new[] { "ItemAttributes", "Request", "Images","Tracks","Large"};
            request.Sort = "salesrank";
            ItemSearchRequest[] requests = new [] { request };

            ItemSearch itemSearch = new ItemSearch();
            //itemSearch.AssociateTag = "myassociatetag-20";
            itemSearch.AWSAccessKeyId = "1VS4R96SQ5CBAA9A87G2";
            itemSearch.Request = requests;

            try
            {
                ItemSearchResponse response = service.ItemSearch(itemSearch);
                Items info = response.Items[0];
                Item[] items = info.Item;
                for (int i = 0; i < items.Length; i++)
                {
                    Item item = items[i];
                    
                }
            }
            catch (Exception ex)
            {
               
            }
            return null;
        }
    }
}